<script setup>
import { ref } from 'vue'
// import AssignRole from './components/assignRole.vue'

import { useConfirm } from '@/hooks/useConfirm'

import tableData from '~mock/user'

// 表单状态
const filterState = ref(true)
// 表单数据
const formData = {
  pagenum: 1,
  pagesize: 10,
  username: '',
  mobile: '',
  role_name: '',
  created_at: '',
  updated_at: '',

  created_at_temp: [], // el-date-picker组件保存是数组
  updated_at_temp: [] // el-date-picker组件保存是数组
}

// 分页
const onSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const onCurrentChange = (val) => {
  console.log(`current page: ${val}`)
}

// 用户删除
const onDelete = () => {
  useConfirm()
}
// 批量选择
let ids = ref([])
const onSelectionChange = (val) => {
  ids.value = val
}
</script>
<template>
  <Box>
    <!-- 逻辑层 -->
    <!-- <Info ref="infoRef" /> -->
    <!-- <AssignRole ref="assignRoleRef" /> -->
    <!-- 逻辑层 -->

    <!-- 筛选 -->
    <template #filter v-if="filterState">
      <el-form :inline="true" :model="formData">
        <el-form-item label="登录地址">
          <el-input placeholder="请输入登录地址" v-model="formData.username" />
        </el-form-item>
        <el-form-item label="用户名称">
          <el-input placeholder="请输入用户名称" v-model="formData.mobile" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary"> <span class="iconfont icon-sousuo"></span>搜索 </el-button>
          <el-button type="default"> 重置 </el-button>
        </el-form-item>
      </el-form>
    </template>
    <!-- 筛选 -->
    <!-- 内容 -->
    <!-- 表格 -->
    <el-table :data="tableData.data" :border="true" @selection-change="onSelectionChange">
      <el-table-column label="序号" prop="id" align="center" width="200"></el-table-column>
      <el-table-column label="会话编号" align="center" width="400">
        <template #default="scope">
          <span>{{ scope.row.account }}</span>
        </template>
      </el-table-column>
      <el-table-column label="登录名称" align="center" width="200">
        <template #default="scope">
          <el-tag>{{ scope.row.nickname }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="部分名称" align="center" width="200">
        <template #default="scope">
          <el-tag>{{ scope.row.nickname }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="主机" prop="mobile" align="center" width="200"></el-table-column>
      <el-table-column
        label="登录地点"
        prop="created_at"
        align="center"
        width="200"
      ></el-table-column>
      <el-table-column
        label="浏览器"
        prop="created_at"
        align="center"
        width="200"
      ></el-table-column>
      <el-table-column
        label="操作系统"
        prop="created_at"
        align="center"
        width="200"
      ></el-table-column>
      <el-table-column
        label="登录时间"
        prop="created_at"
        align="center"
        width="200"
      ></el-table-column>
      <el-table-column label="操作" align="center" width="120" fixed="right">
        <el-button type="primary" link size="small" @click="onDelete">
          <span class="iconfont icon-shanchu"></span>强退
        </el-button>
      </el-table-column>
    </el-table>
    <!-- 表格 -->
    <!-- 分页 -->
    <el-pagination
      v-model:current-page="formData.pagenum"
      v-model:page-size="formData.pagesize"
      :page-sizes="[10, 20, 30, 40]"
      :background="true"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
      @size-change="onSizeChange"
      @current-change="onCurrentChange"
    />
    <!-- 分页 -->
    <!-- 内容 -->
  </Box>
</template>
